package com.wcar.product.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wcar.common.entity.Product;
import com.wcar.common.vo.Result;
import com.wcar.product.service.ProductService;
import com.wcar.product.service.impl.ProductServiceImpl;
import com.wcar.product.vo.ProductVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/product/list")
public class ProductController {
    @Autowired
    private ProductServiceImpl productService;
    @PostMapping("/select")
    public Result<Page<Product>> list(@RequestBody ProductVo productVo){
        return productService.list(productVo);
    }
    @PostMapping("/updateProduct")
    public Result<Product> updateProduct(@RequestBody Product product){
        return productService.updateProduct(product);
    }
    @GetMapping("/deleteByProductId")
    public Result<Product> deleteByProductId(@RequestParam Integer productId){
        return productService.deleteByProductId(productId);
    }
    @PostMapping("/insertProduct")
    public Result<Product> insertProduct(@RequestBody Product product){
        return productService.insertProduct(product);
    }
    @GetMapping("/selectAllProduct")
    public Result<List<Product>> selectAllProduct(){
        return productService.selectAllProduct();
    }
}
